1. Field of the Invention
This invention relates to the field of data processing systems. More particularly, this invention relates to the control of which subroutine return mechanism is to be used when returning from a subroutine.
2. Description of the Prior Art
It is known to provide data processing systems supporting subroutines. One type of subroutine execution results from a procedure called during normal program execution whereupon the subroutine executes and at the end of the subroutine a procedure return instruction is executed to redirect program flow to the program instruction following the procedure call program instruction. The mode of operation of the processing system is typically unaltered by such procedure calls.
Exception processing subroutines (such as exception handler routines) may also be supported within a data processing system and are triggered by exceptions/interrupts arising during normal processing. These trigger execution of an exception handling subroutine. Such exception handling subroutines finish with an exception return instruction which triggers a return to an appropriate point within the original program instruction flow (which may be the instruction which gave rise to the exception, the following instruction or some other point). Associated with such exception handling routines it is known to provide a context switch which stores variables characterising the state of the system at the point at which the exception occurred and then restores these variables thereby restoring the context when the exception return instruction executes. The behavior upon execution of the exception return instruction, such as restoring context variables from a stack memory, or other context restoring operations, is different from the behavior when a procedure return instruction is executed. In order that the two different types of behavior can appropriately be invoked at the end of a subroutine it is known to provide separate return instructions respectively serving to trigger exception return processing or procedure return processing.
The consequence of this known arrangement is that it is necessary for subroutine programs to be written in a way such that the return instruction at the end is appropriate to the nature of the subroutine. For this reason, it is normal for some subroutine programs, such as exception handling subroutines, to be hand written or written in assembler such that the appropriate exception return instruction may be used to terminate the subroutine so that when executed the necessary context restore and other operations will be performed when the return is made. This requirement to hand write or write in assembly exception handling subroutines is a disadvantage since it precludes using high level computer languages, such as C, to write the entirety of exception handling code and other subroutines.